<?php 
if($_GET['act']=='delete'&&$_POST['submit']!=''){
    for($i=0;$i<count($_POST['selectbox']);$i++)
    {
        $query = "delete from ".DBPREFIX."exam where exam_id=".$_POST['selectbox'][$i];
        $result = $db->query($query);
    }
    if($result){
        fs_showmsg('删除成功!');
    }
    else{
        fs_showmsg('删除失败!');
    }
}
?>
<form action="?do=elist&&act=delete" method="post" onsubmit="return checkBoxSelect()">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="CContent">
  <tr><td>
    <div class="submenu_t">
            <ul>
                <li><strong><?php if(fs_get_value('t')=='e'){echo '考试';}else{echo '练习';} ?>试卷列表</strong></li>
            </ul>
    </div>
    </td>
    </tr>
    <tr><td>
                    <table width="100%" border="0" cellpadding="0" cellspacing="0" class="question_list" id="tblist">
                            <thead>
                                    <tr>
                                            <th></th>
                                        <th>试卷名称</th>
                                        <?php
                                        if(fs_get_value('t')=='e'){?>
                                        <th>试卷总分数</th>
                                        <th>实际总分数</th>
                                        <th>考试时间</th>
                                        <?php
                                        }
                                        ?>
                                        
                                        <th>现有题目数量</th>
                                        
                                        <th>出题时间</th>
                                        <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                    
                                            <?php
                                            if(fs_get_value('t')=='e')
                                                $query = "select * from ".DBPREFIX."exam where exam_pubuid=".$teacher_id." and type=1";
                                            else
                                                $query = "select * from ".DBPREFIX."exam where exam_pubuid=".$teacher_id." and type=0";
                                            $result = $db->query($query);
                                            while($row = $db->fetch_array($result))
                                            {
                                                $count_sql = "select * from ".DBPREFIX."exam_thread where exam_id=".$row['exam_id'];
                                                $count_query = $db->query($count_sql);
                                                $num2 = 0;
                                                $num3 = 0;
                                                $num4 = 0;
                                                $count = 0;
                                                while($count_row = $db->fetch_array($count_query))
                                                {   
                                                    $num_sql = "select count(*) as num from ".DBPREFIX."examconnect where thread_id=".$count_row['thread_id'];
                                                    $num_query= $db->query($num_sql);
                                                    $num1= $db->fetch_array($num_query);//print_r($num1);
                                                    $num2 += $num1['num'];//echo $num2;
                                                    $num3 = $num1['num'];
                                                    $num4=(intval($count_row['perscore']))*$num3;
                                                    $count += $num4;
                                                }
                                            ?>
                                            <tr>
                                                    <td><input type="checkbox" name="selectbox[]" value="<?php echo $row['exam_id']?>" /></td>
                                                    <td><?php echo $row['exam_name']?></td>
                                                    <?php
                                                    if(fs_get_value('t')=='e'){?>
                                                    <td><?php echo $row['exam_score']?></td>
                                                    
                                                    <td><font color=red><?php echo $count;?>分</font></td>
                                                    <td><?php echo $row['exam_time'];?>分钟</td>
                                                    <?php
                                                        }
                                                    ?>
                                                    <!--<td><?php if($row['exam_diff'])
                                                               {
                                                                    for($i=0;$i<$row['exam_diff'];$i++){
                                                                        echo '☆'; }                                                   
                                                                }
                                                                else{ echo "暂无说明";}?></td>-->

                                                    <td><?php echo $num2;?>个</td>
                                                    
                                                    <td><?php echo date("Y-m-d H:i:s",$row['exam_pubtime']);?></td>
                                                    <td><input type="button" value="编辑试卷" class="add_bg_g" onclick="goAddTest(examid=<?php echo $row['exam_id']?>)" /><input type="button" value="查看试卷" class="add_bg_g" onclick="javascript:window.location.href='?do=showexam&id=<?php echo $row['exam_id']?>'" /></td>
                                            </tr>
                                            <?php
                                            }
                                            ?>
                                            
                                    
                            </tbody>
                    </table>
            </td></tr>
    <tr><td>
    <div class="submenu_b">
            <ul>
                <li><input type="button" name="selectall" id="allselect" value="全选"/></li>
		<li><input type="button" name="noneselect" id="noneselect" value="全不选"/></li>
        <li><input type="button" name="nonesselect" id="elseselect" value="反选"/></li>
		<li><input type="submit" name="submit"   value="删除"/></li>
            </ul>
    </div>
    </td>
    </tr>
</table>
</form>